#ifndef __HEMS_CAN_DEF_H__
#define __HEMS_CAN_DEF_H__

#define HEMS_RECV_ID_STD_MAX_NUM 16
#define HEMS_RECV_ID_EXT_MAX_NUM 64
#define HEMS_RECV_ID_MAX_NUM (HEMS_RECV_ID_STD_MAX_NUM + HEMS_RECV_ID_EXT_MAX_NUM)

#define NODE_TYPE_HEM1601 0x01
#define NODE_TYPE_HEM1602 0x02
#define NODE_TYPE_HEM2001 0x03
#define NODE_TYPE_HEM6801 0x04
// 后续备用

// HEMxxxxC系列扩展IO模块节点ID定义
#define 	NODEID_HEM1601       0x00
#define 	NODEID_HEM1601_LAST  0x07
#define 	NODEID_HEM1602       0x08
#define 	NODEID_HEM1602_LAST  0x0f
#define 	NODEID_HEM2001       0x10
#define 	NODEID_HEM2001_LAST  0x17
#define   	NODEID_HEM1603       0x18
#define 	NODEID_HEM1603_LAST  0x1f
#define 	NODEID_HEM6801       0x20
#define 	NODEID_HEM6801_LAST  0x27

	// 后续备用

// HEC1016主控与HEM扩展IO模块CAN通信ID定义
#define	ID_DOWN_PWM0003  		0x0c100000
#define	ID_DOWN_PWM6063  		0x0c100f00
#define	ID_DOWN_PWMI0003  		0x0c101000
#define	ID_DOWN_PWMI6063  		0x0c101f00
#define	ID_DOWN_AO0003  		0x0c102000
#define	ID_DOWN_AO1215  		0x0c102300
#define	ID_DOWN_DO  			0x0c102400
#define	ID_DOWN_SET_PARA  		0x0c000000
#define	ID_UP_ACK_PARA    		0x00300000
#define	CMD_SET_PARA_NODEID       	0x01
#define	CMD_SET_PARA_BAUDRATE     	0x02
#define	CMD_SET_PARA_INMODE       	0x03
#define	CMD_SET_PARA_AIDEADZONE   	0x04
#define	CMD_SET_PARA_ERRINTERVAL  	0x05
#define	CMD_SET_PARA_UP_CYCLE_MAX   0x06
#define CMD_SET_PARA_UP_CYCLE_MIN   0x07
#define CMD_SET_PARA_PWMI_PID     	0x08
#define CMD_SET_PARA_PORT_MODE      0x09
#define CMD_SET_PARA_PWM_FREQ       0x0A
#define CMD_SET_PARA_CAN_TERMINAL_RISISTOR 0x64
#define	ID_UP_AI0003  	0x1c100000
#define	ID_UP_AI6063  	0x1c100f00
#define	ID_UP_PWMI0003  0x1c101000
#define	ID_UP_PWMI6063  0x1c101f00
#define	ID_UP_PIF0003  	0x1c102000
#define	ID_UP_PIF2831  	0x1c102700
#define	ID_UP_PIC0001  	0x1c102800
#define	ID_UP_PIC1415  	0x1c102f00
#define	ID_UP_DI   		0x1c103000
#define	ID_UP_ERR  		0x1c103100

// 输入端口可选模式，需要跟HEC1016主控端的定义一致
#define	MODE_IN_AI5V      0
#define	MODE_IN_AI32V     1
#define	MODE_IN_AI20MA    2
#define	MODE_IN_AI30KOHM  3
#define	MODE_IN_DI_HIGH   4
#define	MODE_IN_DI_LOW    5

// HEM系列扩展IO模块运行状态
#define	STATUS_INITING           0x00
#define	STATUS_INIT_OK           0x01
#define	STATUS_RUNNING           0x02
#define	STATUS_SETINMODE         0x03
#define	STATUS_SETNODEID         0x04
#define	STATUS_SETBAUDRATE       0x05
#define	STATUS_SETAIDEADZONE     0x06
#define	STATUS_SETERRINTERVAL    0x07
#define	STATUS_SETAIINTERVAL     0x08
#define	STATUS_SETINMODE_OK      0x09
#define	STATUS_SETNODEID_OK      0x0a
#define	STATUS_SETBAUDRATE_OK    0x0b
#define	STATUS_SETAIDEADZONE_OK  0x0c
#define	STATUS_SETERRINTERVAL_OK 0x0d
#define	STATUS_SETAIINTERVAL_OK  0x0e

#endif // __HEMS_CAN_DEF_H__
